
public class LogicalTimeStamp extends TimeStamp {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int time;
	public LogicalTimeStamp(String local_name) {
		time = 0;
		this.setLocal_name(local_name);
	}
	
	@Override
	public void increase() {
		time ++;
		//System.out.println("increase: " + time);
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	@Override
	public void show() {
		System.out.println(time);
	}

	@Override
	public void update(TimeStamp timeStamp) {
		int t = ((LogicalTimeStamp)timeStamp).getTime();
		time = Math.max(time, t);
		
	}

	@Override
	public int compareTo(TimeStamp o) {
		LogicalTimeStamp lts = (LogicalTimeStamp)o;
		if(lts.getLocal_name().equals(local_name)){
			if(time<lts.getTime()){
				return -1;
			}
			else if(time > lts.getTime()){
				return 1;
			}
			else{
				return 0;
			}
		}else{
			return 0;
		}
	}

	@Override
	public String toString() {
		return time + "";
	}


}
